package xyf.p02.stack_queue;

import java.util.Stack;

/**
 * ClassName: J009_QueueByTwoStack
 * Description:
 * Author: xyf
 * Date: 9/3/22 6:19 PM
 * Version: 1.0
 **/
public class J009_QueueByTwoStack
{
    class CQueue
    {
        private Stack<Integer> stack = new Stack();

        private Stack<Integer> help = new Stack();

        public CQueue()
        {

        }

        public void appendTail(int value)
        {
            while (!stack.isEmpty())
            {
                help.push(stack.pop());
            }

            stack.push(value);

            while (!help.isEmpty())
            {
                stack.push(help.pop());
            }
        }

        public int deleteHead()
        {
            if (stack.isEmpty())
            {
                return -1;
            }
            return stack.pop();
        }
    }
}